﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using YJKRevitCode.ElmentSearchUtility.LinkDocumentSuite;
using YJKRGeometry;
using SectionSignAndFilled.StairsRoomSection.Kit;

namespace SectionSignAndFilled.StairsRoomSection.SignElems
{
	public class RailingComparison
	{
		public int Compare(BaseLinkDocumentResultBean x, BaseLinkDocumentResultBean y)
		{
			if (x == null)
			{
				if (y == null)
				{
					return 0;
				}
				return -1;
			}
			else
			{
				if (y == null)
				{
					return 1;
				}
				Railing railing = x.UseElement as Railing;
				List<Curve> list = railing.GetPath() as List<Curve>;
				Transform totalTransform = x.GetTotalTransform();
				list = CommonFun.TranCurve(list, totalTransform);
				Curve curve = list[0];
				double z = curve.GetEndPoint(0).Z;
				Railing railing2 = y.UseElement as Railing;
				List<Curve> list2 = railing2.GetPath() as List<Curve>;
				x.GetTotalTransform();
				list2 = CommonFun.TranCurve(list2, totalTransform);
				Curve curve2 = list2[0];
				double z2 = curve2.GetEndPoint(0).Z;
				if (Geometry.LessThan(z, z2))
				{
					return -1;
				}
				return 1;
			}
		}
	}
}
